package gui.fileImportWindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class FileImportWindow extends javax.swing.JFrame {
	private JLabel importedDataLabel;
	private JLabel erronousDataLabel;
	private JLabel erronousDataNumberLabel;
	private JTextPane informationTextPane;
	private JProgressBar progressBar;
	private JButton closeButton;
	private JLabel alreadyContainedDataNumberLabel;
	private JScrollPane informationTextScrollPane;
	private JLabel successfulImportsNumberLabel;
	private JLabel alreadyContainedDataLabel;

	private final FileImportWindowController controller;

	/**
	 * Auto-generated main method to display this JFrame
	 */

	public FileImportWindow(File file) throws FileNotFoundException {
		super();
		this.controller = new FileImportWindowController(file, this);
		this.setUndecorated(true);
		this.initGUI();
	}

	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout(this.getContentPane());
			this.getContentPane().setLayout(thisLayout);
			this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
			{
				this.importedDataLabel = new JLabel();
				this.importedDataLabel.setText("Importierte Datensätze");
				this.importedDataLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			{
				this.alreadyContainedDataLabel = new JLabel();
				this.alreadyContainedDataLabel.setText("Bereits vorhandene Datensätze");
				this.alreadyContainedDataLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			{
				this.successfulImportsNumberLabel = new JLabel();
				this.successfulImportsNumberLabel.setText("0");
				this.successfulImportsNumberLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			{
				this.informationTextScrollPane = new JScrollPane();
				{
					this.informationTextPane = new JTextPane();
					this.informationTextScrollPane.setViewportView(this.informationTextPane);
					this.informationTextPane.setBorder(BorderFactory.createTitledBorder("Aufgetretene Fehler"));
				}
			}
			{
				this.alreadyContainedDataNumberLabel = new JLabel();

				this.alreadyContainedDataNumberLabel.setText("0");
				this.alreadyContainedDataNumberLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			{
				this.closeButton = new JButton();
				this.closeButton.setText("Abbrechen");
				this.closeButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						FileImportWindow.this.controller.closeAction();
					}
				});
			}
			{
				// this.progressBar = new JProgressBar(0, this.numberOfLines);
				this.progressBar = new JProgressBar(0, 100);
				this.progressBar.setValue(0);
				this.progressBar.setStringPainted(true);
			}
			{
				this.erronousDataNumberLabel = new JLabel();
				this.erronousDataNumberLabel.setText("0");
				this.erronousDataNumberLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			{
				this.erronousDataLabel = new JLabel();
				this.erronousDataLabel.setText("Fehlerhafte Datensätze");
				this.erronousDataLabel.setFont(new java.awt.Font("Bitstream Charter", 0, 16));
			}
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12).addGroup(
					thisLayout.createParallelGroup().addGroup(
							thisLayout.createSequentialGroup().addGroup(
									thisLayout.createParallelGroup().addComponent(this.progressBar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 378, GroupLayout.PREFERRED_SIZE)
											.addComponent(this.erronousDataLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 373, GroupLayout.PREFERRED_SIZE).addComponent(
													this.alreadyContainedDataLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 373, GroupLayout.PREFERRED_SIZE).addComponent(
													this.importedDataLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 373, GroupLayout.PREFERRED_SIZE)).addPreferredGap(
									LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
									thisLayout.createParallelGroup().addComponent(this.closeButton, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 135, GroupLayout.PREFERRED_SIZE)
											.addGroup(
													thisLayout.createSequentialGroup().addPreferredGap(this.closeButton, this.erronousDataNumberLabel, LayoutStyle.ComponentPlacement.INDENT).addGroup(
															thisLayout.createParallelGroup().addComponent(this.erronousDataNumberLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 123,
																	GroupLayout.PREFERRED_SIZE).addComponent(this.alreadyContainedDataNumberLabel, GroupLayout.Alignment.LEADING,
																	GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE).addComponent(this.successfulImportsNumberLabel,
																	GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE))))).addComponent(
							this.informationTextScrollPane, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 525, GroupLayout.PREFERRED_SIZE)).addContainerGap(12, 12));
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12).addGroup(
					thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.importedDataLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52,
							GroupLayout.PREFERRED_SIZE).addComponent(this.successfulImportsNumberLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.alreadyContainedDataLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52,
									GroupLayout.PREFERRED_SIZE).addComponent(this.alreadyContainedDataNumberLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52,
									GroupLayout.PREFERRED_SIZE)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.erronousDataLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52,
									GroupLayout.PREFERRED_SIZE).addComponent(this.erronousDataNumberLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE))
					.addGap(12).addComponent(this.informationTextScrollPane, GroupLayout.PREFERRED_SIZE, 208, GroupLayout.PREFERRED_SIZE).addGap(12).addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.closeButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
									GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(this.progressBar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 21,
									GroupLayout.PREFERRED_SIZE)).addContainerGap(11, 11));
			this.pack();
			this.setSize(549, 451);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

	public void setNumberOfImportedPlayers(int number) {
		this.successfulImportsNumberLabel.setText(new Integer(number).toString());
	}

	public int getNumberOfImportetPlayers() {
		return Integer.parseInt(this.successfulImportsNumberLabel.getText());
	}

	public void setNumberOfErronousData(int number) {
		this.alreadyContainedDataNumberLabel.setText(new Integer(number).toString());
	}

	public int getNumberOfErronousData() {
		return Integer.parseInt(this.alreadyContainedDataNumberLabel.getText());
	}

	public String getErrorText() {
		return this.informationTextPane.getText();
	}

	public void setErrorText(String text) {
		this.informationTextPane.setText(text);
	}

	public void updateProgressBar(int value) {
		this.progressBar.setValue(value);
	}

	public int getProgressBarValue() {
		return this.progressBar.getValue();
	}

	public JButton getCloseButton() {
		return this.closeButton;
	}

	public FileImportWindowController getController() {
		return this.controller;
	}

	public JLabel getErronousDataNumberLabel() {
		return this.erronousDataNumberLabel;
	}

	public JTextPane getInformationTextPane() {
		return this.informationTextPane;
	}

	public JLabel getAlreadyContainedDataNumberLabel() {
		return this.alreadyContainedDataNumberLabel;
	}

	public JLabel getSuccessfulImportsNumberLabel() {
		return this.successfulImportsNumberLabel;
	}

	public void setProgressBar(int maxValue) {
		this.progressBar.setMaximum(maxValue);
	}

	public void incrementProgressBar() {
		this.progressBar.setValue(this.progressBar.getValue() + 1);
	}
}
